﻿Namespace Twitter.Common

    Public Class TweetButtonProperties
        'Estos son parametros del QueryString de https://twitter.com/share
        ''' <summary>
        ''' URL a twitear
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>Puede utilizar el abreviado "http://bit.ly/palabra-clave" para resumir una URL, para ello recuerde utilizar adicionalmente el parametro COUNT-URL para indicar el URL real</remarks>
        Property Url As String = ""
        ''' <summary>
        ''' Cuenta asociada al tweet
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Via As String = ""
        ''' <summary>
        ''' Texto a mostrar al twitear
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Text As String = ""
        ''' <summary>
        ''' Cuentas relacionadas al tweet
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Related As New List(Of String)
        ''' <summary>
        ''' Posicion del contador de tweets
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Count As TweetButtonCountValues = TweetButtonCountValues.Horizontal
        ''' <summary>
        ''' Idioma del tweet
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Language As TweetButtonLanguage = TweetButtonLanguage.Espanol
        ''' <summary>
        ''' URL larga del URL a twitear
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property CountUrl As String = ""
        ''' <summary>
        ''' Palabra(s) clave (para menciones)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Hashtag As String = ""
        ''' <summary>
        ''' Texto a mostrar por cada hashtag
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property HashtagText As String = ""
        ''' <summary>
        ''' Tamaño del boton final (mediano, grande)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Property Size As TweetButtonSizes = TweetButtonSizes.Medium
    End Class

    Public Class FollowButtonProperties
        ''' <summary>
        ''' Nombre de la cuenta a seguir
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property ScreenName As String = ""
        ''' <summary>
        ''' Mostrar el conteo de los seguidores
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property ShowCount As Boolean = False
        ''' <summary>
        ''' Idioma del boton
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Language As TweetButtonLanguage = TweetButtonLanguage.Espanol
        ''' <summary>
        ''' Ancho del boton, en numero o porcentaje
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>Solo funciona en la version Javascript del boton</remarks>
        Public Property Width As String = ""
        ''' <summary>
        ''' Alineacion del texto
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks>Solo funciona en la version Javascript del boton</remarks>
        Public Property Align As FollowButtonAlign = FollowButtonAlign.Left
        ''' <summary>
        ''' Mostrar el nombre de usuario a seguir
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property ShowScreenName As Boolean = True
    End Class

    Public Class WidgetProperties
        ''' <summary>
        ''' Indica el tipo de widget a crear
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Type As WidgetTypes = WidgetTypes.Profile
        Public Property ScreenName As String = ""
        Public Property SearchProperties As New WidgetSearchProperties
        Public Property Interval As Long = 30000
        Public Property Width As Integer = 250
        Public Property Height As Integer = 300
        Public Property Shell As New WidgetStyle
        Public Property Tweets As New WidgetStyle
        Public Property Features As New WidgetFeatures
        Public Property TweetsToShow As Integer = 5
    End Class

    Public Class WidgetSearchProperties
        Public Property Search As String = ""
        Public Property Title As String = ""
        Public Property Subject As String = ""
    End Class

    Public Class WidgetStyle
        Public Property Background As System.Drawing.Color = Drawing.Color.Gray
        Public Property Color As System.Drawing.Color = Drawing.Color.Black
        Public Property Links As System.Drawing.Color = Drawing.Color.Navy

        Public Function GetBackground() As String
            Return System.Drawing.ColorTranslator.ToHtml(Background)
        End Function

        Public Function GetColor() As String
            Return System.Drawing.ColorTranslator.ToHtml(Color)
        End Function

        Public Function getLinks() As String
            Return System.Drawing.ColorTranslator.ToHtml(Links)
        End Function
    End Class

    Public Class WidgetFeatures
        Public Property Scrollbar As Boolean = False
        Public Property DoLoop As Boolean = False
        Public Property Live As Boolean = False
        Public Property Behavior As WidgetBehaviors = WidgetBehaviors.All

        Public Function GetScrollbar() As String
            Return IIf(Scrollbar = True, "true", "false")
        End Function

        Public Function GetLoop() As String
            Return IIf(DoLoop = True, "true", "false")
        End Function

        Public Function GetLive() As String
            Return IIf(Live = True, "true", "false")
        End Function

        Public Function GetBehavior() As String
            Return IIf(Behavior = WidgetBehaviors.All, "all", "default")
        End Function
    End Class

    Public Enum TweetButtonCountValues
        ''' <summary>
        ''' Sin indicador de tweets
        ''' </summary>
        ''' <remarks></remarks>
        None
        ''' <summary>
        ''' Indicador a la derecha del boton
        ''' </summary>
        ''' <remarks></remarks>
        Horizontal
        ''' <summary>
        ''' Indicador sobre el boton
        ''' </summary>
        ''' <remarks></remarks>
        Vertical
    End Enum

    Public Enum TweetButtonSizes
        ''' <summary>
        ''' Tamaño de boton mediano
        ''' </summary>
        ''' <remarks></remarks>
        Medium
        ''' <summary>
        ''' Tamaño de boton grande
        ''' </summary>
        ''' <remarks></remarks>
        Large
    End Enum

    Public Enum TweetButtonTypes
        Original
        Hashtag
        Mention
    End Enum

    Public Enum TweetButtonLanguage
        ''' <summary>
        ''' Establece el boton en ingles
        ''' </summary>
        ''' <remarks></remarks>
        English
        ''' <summary>
        ''' Establece el boton en español
        ''' </summary>
        ''' <remarks></remarks>
        Espanol
    End Enum

    Public Enum FollowButtonAlign
        ''' <summary>
        ''' Alineacion izquierda
        ''' </summary>
        ''' <remarks></remarks>
        Left
        ''' <summary>
        ''' Alineacion derecha
        ''' </summary>
        ''' <remarks></remarks>
        Right
    End Enum

    Public Enum WidgetTypes
        ''' <summary>
        ''' Widget de perfil
        ''' </summary>
        ''' <remarks></remarks>
        Profile
        ''' <summary>
        ''' Widget de busqueda
        ''' </summary>
        ''' <remarks></remarks>
        Search
    End Enum

    Public Enum WidgetBehaviors
        All
        Normal
    End Enum

    Public Class Functions

        Public Shared Function GetScript() As String
            Dim Script As String = ""
            Script &= vbCrLf
            Script &= "<script>" & vbCrLf
            Script &= " !function(d,s,id){" & vbCrLf
            Script &= "     var js,fjs = d.getElementsByTagName(s)[0];" & vbCrLf
            Script &= "     if(!d.getElementById(id)) {" & vbCrLf
            Script &= "         js = d.createElement(s);" & vbCrLf
            Script &= "         js.id = id;" & vbCrLf
            Script &= "         js.src = ""//platform.twitter.com/widgets.js"";" & vbCrLf
            Script &= "         fjs.parentNode.insertBefore(js, fjs);" & vbCrLf
            Script &= "     }" & vbCrLf
            Script &= " }(document,""script"",""twitter-wjs"");" & vbCrLf
            Script &= "</script>"
            Return Script
        End Function

    End Class

End Namespace